package com.ruoyi.product.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.product.domain.ProParameterValue;
import com.ruoyi.product.service.IProParameterValueService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商品参数值Controller
 * 
 * @author admin
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/value")
public class ProParameterValueController extends BaseController
{
    @Autowired
    private IProParameterValueService proParameterValueService;

    /**
     * 查询商品参数值列表
     */
    @RequiresPermissions("product:value:list")
    @GetMapping("/list")
    public TableDataInfo list(ProParameterValue proParameterValue)
    {
        startPage();
        List<ProParameterValue> list = proParameterValueService.selectProParameterValueList(proParameterValue);
        return getDataTable(list);
    }

    /**
     * 导出商品参数值列表
     */
    @RequiresPermissions("product:value:export")
    @Log(title = "商品参数值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProParameterValue proParameterValue)
    {
        List<ProParameterValue> list = proParameterValueService.selectProParameterValueList(proParameterValue);
        ExcelUtil<ProParameterValue> util = new ExcelUtil<ProParameterValue>(ProParameterValue.class);
        util.exportExcel(response, list, "商品参数值数据");
    }

    /**
     * 获取商品参数值详细信息
     */
    @RequiresPermissions("product:value:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(proParameterValueService.selectProParameterValueById(id));
    }

    /**
     * 新增商品参数值
     */
    @RequiresPermissions("product:value:add")
    @Log(title = "商品参数值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProParameterValue proParameterValue)
    {
        return toAjax(proParameterValueService.insertProParameterValue(proParameterValue));
    }

    /**
     * 修改商品参数值
     */
    @RequiresPermissions("product:value:edit")
    @Log(title = "商品参数值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProParameterValue proParameterValue)
    {
        return toAjax(proParameterValueService.updateProParameterValue(proParameterValue));
    }

    /**
     * 删除商品参数值
     */
    @RequiresPermissions("product:value:remove")
    @Log(title = "商品参数值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(proParameterValueService.deleteProParameterValueByIds(ids));
    }
}
